﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TestTraceWriter.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the TestTraceWriter type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

#define DEBUG

namespace Photon.Diagnostics.Assets
{
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;

    internal class TestTraceWriter : ITraceWriter
    {
        #region Fields

        private readonly List<string> _lines = new List<string>();

        #endregion

        public List<string> Lines
        {
            get { return this._lines; }
        }

        public void WriteLine(string text)
        {
            this.Lines.Add(text);
            Debug.WriteLine(text);
        }

        public void WriteLine(string format, params object[] args)
        {
            this.Lines.Add(string.Format(format, args));
            Debug.WriteLine(format, args);
        }

        public bool RemoveMatch(string text)
        {
            var line = this.Lines.FirstOrDefault(x => x == text);
            return line != null && this.Lines.Remove(line);
        }
    }
}
